
var app = getApp();  // 取得全局App
var localData=require("../../data/data.js")
// 引入SDK核心类
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
// 实例化API核心类
var qqmapsdk = new QQMapWX({
    key: 's1DOBV5nGUOkVhSsXWbg00Vm5zNByLs9' // 必填
});

Page({
   /**
   * 页面的初始数据  
   */
  data: {
    pctype:['车找人','人找车','车找货','货找车'],
    syzd:['置顶2小时(收费4元)','置顶12小时(收费24元)','置顶一天(收费40元)','置顶三天(收费100元)','置顶三十天(收费300元)'],
    cfd:null,
    mdd:null,
    cfdate: null,
    bcdate: null,
    telephone: app.globalData.tel,
    kwnun: 1,
    remarks: null,
    isread: 1,
    username:null
  },
  bindpctypeChange:function(e){
    this.setData({
      index: e.detail.value
    })
  },
  bindsyzdChange: function (e) {
    this.setData({
      index: e.detail.value
    })
  },
  bindDateChange: function (e) {
    this.setData({
      cfdate: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    this.setData({
      bcdate: e.detail.value
    })
  },
  getPhoneNumber (e) {
    console.log("getPhoneNumber",e.detail)
    this.setData({
      telephone: e.detail.code
    })
    app.globalData.tel=e.detail.code;
  },
 onLoad: function () {
  if (app.globalData.userInfo) {
    this.setData({
      username: app.globalData.userInfo.nickName,
    })
  } 
  qqmapsdk.reverseGeocoder({
    location: {
      latitude: app.globalData.location.latitude,
      longitude: app.globalData.location.longitude,
    },
    success: function (addressRes) {
      const result = addressRes.result;
      console.log(addressRes);
      this.setData({
        cfd: result.address,
      })

    }
  })
 },
 formSubmit(e) {
    var frmdata=e.detail.value;
    frmdata["username"]=app.globalData.userInfo.nickName;
    console.log('form发生了submit事件，携带数据为：',frmdata)
    localData.JsonList.push(frmdata);
    console.log('submit事件：',localData)
},
})